import request from '@/utils/request'

export const getMaterialListService = (name) => {
	return request.get('/material/all?name=' + name)
}

export const addMaterialService = (material) => {
	const params = new URLSearchParams()
	for (let key in material) {
		params.append(key, material[key])
	}
	return request.post('/material/add', params)
}

export const deleteMaterialService = (id) => {
	return request.delete('/material/delete?id=' + id)
}

export const updateMaterialService = (currentId, material) => {
	const params = new URLSearchParams()
	params.append('id', currentId)
	for (let key in material) {
		params.append(key, material[key])
	}
	return request.patch('/material/update', params)
}
